load(
    "//tools:defaults.bzl",
    "extract_tokens",
    "markdown_to_html",
    "ng_project",
    "ng_web_test_suite",
    "sass_binary",
    "sass_library",
)

package(default_visibility = ["//visibility:public"])

sass_library(
    name = "m3",
    srcs = [
        "_m3-app.scss",
    ],
    deps = [
        "//src/material/core/style:sass_utils",
        "//src/material/core/tokens:m3_utils",
    ],
)

sass_library(
    name = "m2",
    srcs = [
        "_m2-app.scss",
    ],
    deps = [
        "//src/material/core/style:elevation",
        "//src/material/core/style:sass_utils",
        "//src/material/core/theming:_inspection",
        "//src/material/core/tokens:m2_utils",
    ],
)

ng_project(
    name = "core",
    srcs = [
        "index.ts",
        "line/line.ts",
        "public-api.ts",
    ],
    deps = [
        ":version",
        "//:node_modules/@angular/core",
        "//:node_modules/rxjs",
        "//src:dev_mode_types",
        "//src/material/core:ripple",
        "//src/material/core/animation",
        "//src/material/core/common-behaviors",
        "//src/material/core/datetime",
        "//src/material/core/error",
        "//src/material/core/focus-indicators:internal",
        "//src/material/core/internal-form-field",
        "//src/material/core/option",
        "//src/material/core/private",
        "//src/material/core/selection",
    ],
)

ng_project(
    name = "version",
    srcs = [
        "version.ts",
    ],
    deps = [
        "//:node_modules/@angular/core",
    ],
)

sass_library(
    name = "core_sass",
    srcs = [
        "_core.scss",
    ],
    deps = [
        "//src/material/core/style:elevation",
        "//src/material/core/tokens:token_utils",
    ],
)

sass_library(
    name = "theme_sass",
    srcs = [
        "_core-theme.scss",
    ],
    deps = [
        ":m2",
        "//src/material/core:ripple_sass_theme",
        "//src/material/core/option:theme",
        "//src/material/core/selection/pseudo-checkbox:sass_theme",
        "//src/material/core/style:sass_utils",
        "//src/material/core/theming",
        "//src/material/core/theming:_inspection",
        "//src/material/core/theming:_validation",
        "//src/material/core/tokens:token_utils",
        "//src/material/core/typography",
    ],
)

#################
#  Test targets
#################

ng_project(
    name = "unit_test_sources",
    testonly = True,
    srcs = glob(
        ["**/*.spec.ts"],
        exclude = ["**/*.e2e.spec.ts"],
    ),
    deps = [
        ":core",
        ":ripple",
        "//:node_modules/@angular/core",
        "//:node_modules/@angular/platform-browser",
        "//src/cdk/keycodes",
        "//src/cdk/platform",
        "//src/cdk/testing/private",
        "//src/material/core/animation",
        "//src/material/testing",
    ],
)

ng_web_test_suite(
    name = "unit_tests",
    deps = [":unit_test_sources"],
)

markdown_to_html(
    name = "overview",
    srcs = [
        "core.md",
        "ripple/ripple.md",
    ],
)

extract_tokens(
    name = "tokens",
    srcs = [":theme_sass"],
)

filegroup(
    name = "source-files",
    srcs = glob(["**/*.ts"]),
)

### Ripple
### Cannot be in its own ripple/BUILD.bazel due to breaking docs generation.

sass_library(
    name = "ripple_m3",
    srcs = [
        "ripple/_m3-ripple.scss",
    ],
    deps = [
        "//src/material/core/style:sass_utils",
        "//src/material/core/tokens:m3_utils",
    ],
)

sass_library(
    name = "ripple_m2",
    srcs = [
        "ripple/_m2-ripple.scss",
    ],
    deps = [
        "//src/material/core/style:elevation",
        "//src/material/core/style:sass_utils",
        "//src/material/core/theming:_inspection",
        "//src/material/core/tokens:m2_utils",
    ],
)

sass_library(
    name = "ripple_sass_theme",
    srcs = [
        "ripple/_ripple-theme.scss",
    ],
    deps = [
        ":ripple_m2",
        "//src/material/core/style:sass_utils",
        "//src/material/core/theming",
        "//src/material/core/theming:_inspection",
        "//src/material/core/theming:_validation",
        "//src/material/core/tokens:token_utils",
    ],
)

sass_library(
    name = "ripple_sass",
    srcs = [
        "ripple/_ripple.scss",
    ],
    deps = [
        ":ripple_m2",
        "//src/cdk:sass_lib",
        "//src/material/core/tokens:token_utils",
    ],
)

sass_binary(
    name = "ripple_structure",
    src = "ripple/ripple-structure.scss",
    deps = [
        ":ripple_sass",
    ],
)

ng_project(
    name = "ripple",
    srcs = [
        "ripple/index.ts",
        "ripple/ripple.ts",
        "ripple/ripple-event-manager.ts",
        "ripple/ripple-module.ts",
        "ripple/ripple-ref.ts",
        "ripple/ripple-renderer.ts",
    ],
    assets = [
        ":ripple_structure",
    ],
    deps = [
        "//:node_modules/@angular/core",
        "//src/cdk/a11y",
        "//src/cdk/coercion",
        "//src/cdk/platform",
        "//src/cdk/private",
        "//src/material/core/animation",
        "//src/material/core/common-behaviors",
    ],
)
